View Javadoc

1   package uk.ac.roe.antigen.ant;
2   
3   import javax.swing.JFrame;
4   
5   import org.apache.tools.ant.input.InputHandler;
6   import org.apache.tools.ant.input.InputRequest;
7   import org.apache.tools.ant.input.MultipleChoiceInputRequest;
8   
9   import uk.ac.roe.antigen.dialogs.AbstractFilePropertyInputHandler;
10  import uk.ac.roe.antigen.dialogs.DirPropertyInputHandler;
11  import uk.ac.roe.antigen.dialogs.FilePropertyInputHandler;
12  import uk.ac.roe.antigen.dialogs.RadioPropertyInputHandler;
13  import uk.ac.roe.antigen.dialogs.TextPropertyInputHandler;
14  import uk.ac.roe.antigen.utils.Config;
15  
16  
17  public class GeneralInputHandler implements InputHandler {
18   
19  	private JFrame frame;
20      public GeneralInputHandler(JFrame frame) {
21       this.frame = frame;   
22      }
23    
24      public void handleInput(InputRequest request) {
25       
26          InputHandler handler;
27          if (request instanceof MultipleChoiceInputRequest) {
28          	handler = new RadioPropertyInputHandler(frame);
29          } else {
30              String propertyName = request.getAddproperty();
31              String filePropertySuffix = Config.getProperty("antigen.filepropertysuffix");
32              String dirPropertySuffix = Config.getProperty("antigen.dirpropertysuffix");
33              if (filePropertySuffix!=null && propertyName.endsWith(filePropertySuffix)) {
34              	handler = new FilePropertyInputHandler(frame);
35              } else if (dirPropertySuffix!=null && propertyName.endsWith(dirPropertySuffix)) {
36                  handler = new DirPropertyInputHandler(frame);
37              } else {
38                  handler = new TextPropertyInputHandler(frame);
39              }
40          }
41          handler.handleInput(request);
42          
43      }
44  }
45  
46